package xw.qxypt.modules.baseinfo.controller;

import java.util.Arrays;
import java.util.Map;

import xw.qxypt.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import xw.qxypt.modules.baseinfo.entity.LhpDataWeatherStationHistoryEntity;
import xw.qxypt.modules.baseinfo.service.LhpDataWeatherStationHistoryService;
import xw.qxypt.common.utils.PageUtils;
import xw.qxypt.common.utils.R;



/**
 * 
 *
 * @author xw
 * @email 
 * @date 2019-11-28 16:38:08
 */
@RestController
@RequestMapping("baseinfo/lhpdataweatherstationhistory")
public class LhpDataWeatherStationHistoryController {
    @Autowired
    private LhpDataWeatherStationHistoryService lhpDataWeatherStationHistoryService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("baseinfo:lhpdataweatherstationhistory:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = lhpDataWeatherStationHistoryService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("baseinfo:lhpdataweatherstationhistory:info")
    public R info(@PathVariable("id") String id){
        LhpDataWeatherStationHistoryEntity lhpDataWeatherStationHistory = lhpDataWeatherStationHistoryService.getById(id);

        return R.ok().put("lhpDataWeatherStationHistory", lhpDataWeatherStationHistory);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("baseinfo:lhpdataweatherstationhistory:save")
    public R save(@RequestBody LhpDataWeatherStationHistoryEntity lhpDataWeatherStationHistory){
        lhpDataWeatherStationHistoryService.save(lhpDataWeatherStationHistory);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("baseinfo:lhpdataweatherstationhistory:update")
    public R update(@RequestBody LhpDataWeatherStationHistoryEntity lhpDataWeatherStationHistory){
        ValidatorUtils.validateEntity(lhpDataWeatherStationHistory);
        lhpDataWeatherStationHistoryService.updateById(lhpDataWeatherStationHistory);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("baseinfo:lhpdataweatherstationhistory:delete")
    public R delete(@RequestBody String[] ids){
        lhpDataWeatherStationHistoryService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
